﻿Imports System.Data.SQLite

Public Class EinstellungenFRM

#Region " Private Sub ButtonDBAnlegen_Click "
    Private Sub ButtonDBAnlegen_Click(sender As Object, e As EventArgs) Handles ButtonDBAnlegen.Click
        Dim connect As New SQLiteConnection()
        connect.ConnectionString = "Data Source=VorratsDaten.s3db;"
        connect.Open()
        connect.Close()
        Dim createQuery As String = "--
-- File generated with SQLiteStudio v3.1.1 on Mo Nov 28 11:03:11 2016
--
-- Text encoding used: System
--
PRAGMA foreign_keys = off;
BEGIN TRANSACTION;

-- Table: Artikel
DROP TABLE IF EXISTS Artikel;
CREATE TABLE Artikel (id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT UNIQUE NOT NULL, LagerBestandME1 REAL, LagerBestandME2 REAL, ME1 INTEGER NOT NULL REFERENCES Mengeneinheiten (id), ME2 INTEGER NOT NULL REFERENCES Mengeneinheiten (id));

-- Table: Chargen
DROP TABLE IF EXISTS Chargen;
CREATE TABLE Chargen (id INTEGER PRIMARY KEY AUTOINCREMENT, Kennung TEXT UNIQUE NOT NULL, Verfallsdatum DATE NOT NULL, Menge REAL NOT NULL, EAN INTEGER NOT NULL REFERENCES EANcodes (id));

-- Table: EANcodes
DROP TABLE IF EXISTS EANcodes;
CREATE TABLE EANcodes (id INTEGER PRIMARY KEY AUTOINCREMENT, Code TEXT UNIQUE NOT NULL, Artikel INTEGER NOT NULL REFERENCES Artikel (id), MeUmrechnungsfaktor REAL NOT NULL);

-- Table: Mengeneinheiten
DROP TABLE IF EXISTS Mengeneinheiten;
CREATE TABLE ""Mengeneinheiten"" (
  ""id"" Integer PRIMARY KEY AUTOINCREMENT,
  ""Name"" TEXT UNIQUE NOT NULL

-- Table: BuchungsProtokoll
DROP TABLE IF EXISTS BuchungsProtokoll;
CREATE TABLE BuchungsProtokoll (id Integer PRIMARY KEY AUTOINCREMENT, Datum DATE UNIQUE NOT NULL, Artikel INTEGER NOT NULL REFERENCES Artikel (id), EAN INTEGER NOT NULL REFERENCES EANcodes (id), Menge REAL NOT NULL, Zugang INTEGER NOT NULL);

COMMIT TRANSACTION;
PRAGMA foreign_keys = on;"
        Dim command As SQLiteCommand
        connect.ConnectionString = "Data Source=VorratsDaten.s3db;"
        connect.Open()
        command = connect.CreateCommand
        command.CommandText = createQuery
        command.ExecuteNonQuery()
        command.Dispose()
        connect.Close()
    End Sub
#End Region

#Region " Button1_Click-Ereignis "
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.DialogResult = DialogResult.OK
    End Sub
#End Region

#Region " Button2_Click-Ereignis "
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim mefenster As New MEeditForm
        mefenster.ShowDialog()
    End Sub
#End Region

#Region " Button3_Click-Ereignis "
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles ButtonArtikel.Click
        Dim artikelFenster As New ArtikelFRM
        artikelFenster.ShowDialog()
    End Sub
#End Region

End Class